package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a
 * Date: 2022-08-30
 * Time: 23:31
 */
public class Demo6 {
    private static Thread thread = null;

    //有20个线程，需要同时启动。
    //每个线程按0-19的序号打印，如第一个线程需要打印0
    //请设计代码，在main主线程中，等待所有子线程执行完后，再打印 ok
    public static void main(String[] args) throws InterruptedException {
        for(int i = 0; i < 20; i++){
            int tmp = i;
            thread = new Thread(() -> {
                System.out.println(tmp);
            });
            thread.start();
        }
        thread.join();
        System.out.println("ok");
    }
}
